/**
 * 2017年3月2日
 */
package demo;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
/**
 * @author Alex
 *
 */
import org.codehaus.jackson.map.ObjectMapper;
public class JsonExamples {

	/**
	 * @param args
	 */
	static class Chart{
		public String title;
		public String subTitle;
	}
	static class LineChart extends Chart{
		public String[] x;
		public double[] y;
	}
	static class PieChart extends Chart{
		public Map<String,Double> ratio;
		
	}
	public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException {
		// TODO Auto-generated method stub
		
		String str = "{\"x\":[1,2,3,4,5,6,7],\"y\":[1,2,3,4,5,6,7],\"title\":\"test title\",\"subTitle\":\"sub title\"}";
		ObjectMapper om = new ObjectMapper();
		String st2 = "{\"title\":\"eh\",\"subTitle\":\"fff\",\"ratio\":{\"zzd\":0.5,\"alex\":0.5}}";
		LineChart lc = om.readValue(str, LineChart.class);
		PieChart pc = om.readValue(st2, PieChart.class);
		
		System.out.println();
	}

}
